package org.vuzya.motivateme.helpers;

import org.vuzya.motivateme.R;
import org.vuzya.motivateme.quickaction.ActionItem;
import org.vuzya.motivateme.quickaction.QuickAction;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;

public class QuickActionHelper {
	private static ActionItem[] MENU_CURRENT_BUSINESS_LIST = null;
	private static ActionItem[] MENU_DONE_BUSINESS_LIST = null;
		
	public static ActionItem[] getQuickActionBusinessListItems(Resources res){
		if(MENU_CURRENT_BUSINESS_LIST != null){
			return MENU_CURRENT_BUSINESS_LIST;
		}
		String[] arr = res.getStringArray(R.array.quickaction_current_business_items_text);
		MENU_CURRENT_BUSINESS_LIST = new ActionItem[] {
				new ActionItem(arr[0], res.getDrawable(R.drawable.quickaction_done)),
				new ActionItem(arr[1], res.getDrawable(R.drawable.quickaction_motivate)),
				new ActionItem(arr[2], res.getDrawable(R.drawable.quickaction_progress)),
				new ActionItem(arr[3], res.getDrawable(R.drawable.quickaction_edit)),
				new ActionItem(arr[4], res.getDrawable(R.drawable.quickaction_delete)) 
			};
		return MENU_CURRENT_BUSINESS_LIST;
	}
	
	public static ActionItem[] getQuickActionDoneBusinessListItems(Resources res){
		if(MENU_DONE_BUSINESS_LIST != null){
			return MENU_DONE_BUSINESS_LIST;
		}
		String[] arr = res.getStringArray(R.array.quickaction_finished_business_items_text);
		MENU_DONE_BUSINESS_LIST = new ActionItem[] {
				new ActionItem(arr[0], res.getDrawable(R.drawable.quickaction_undone)),
				new ActionItem(arr[1], res.getDrawable(R.drawable.quickaction_progress)),
				new ActionItem(arr[2], res.getDrawable(R.drawable.quickaction_edit)),
				new ActionItem(arr[3], res.getDrawable(R.drawable.quickaction_delete)) 
			};
		return MENU_DONE_BUSINESS_LIST;
	}
	
	public static void fillQuickAction(QuickAction qa, ActionItem[] aitems){
		for (int i = 0; i < aitems.length; i++) {
			qa.addActionItem(aitems[i]);
		}
	}
	
	public static void fillQuickAction(QuickAction qa, String[] titles, Drawable[] icons){
		for(int i=0; i<titles.length; i++){
			qa.addActionItem(new ActionItem(titles[i], icons[i]));
		}
	}
	
	public static void fillQuickAction(QuickAction qa, String[] titles, int[] icons, Context context){
			Resources res = context.getResources();
			Drawable[] drawables = new Drawable[icons.length];
			for (int i = 0; i < icons.length; i++) {
				drawables[i] = res.getDrawable(icons[i]);
			}
	}
}
